<?php

// @filename   mtypes.php

class madmin extends Model {

    function madmin() {
        parent::Model();
    }

    function check_admin_login($admin_name,$admin_pwd) {
        $this->db->where(array('admin_name'=>$admin_name));
        $query = $this->db->get('admin');
        if($query->num_rows > 0) {
            $res = $query->row();
            if($res->admin_pwd == $admin_pwd) {
                return '0';
            } else {
                return '2';
            }
        } else {
            return '1';
        }
    }
    
    function check_admin_pwd($admin,$pwd){
    	$pwd = sha1($pwd);
    	$this->db->where(array('admin_name'=>$admin));
    	$query = $this->db->get('admin');
    	if($query->num_rows > 0) {
            $res = $query->row();
            if($res->admin_pwd == $pwd) {
                return true;
            } else {
                return false;
            }
        } else {
            return false;
        }
    }
    
    function update_admin_pwd($admin,$pwd){
    	$pwd = sha1($pwd);
    	return $this->db->update('admin',array('admin_pwd'=>$pwd),array('admin_name'=>$admin));
    }

}

?>